<template>
<html>
<el-container style="height: 100vh; border: 1px solid #eee">
  <!-- 左边侧边栏 -->
  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    <el-menu :default-openeds="['1']" router>
      <el-submenu index="1">
        <template slot="title"><i class="el-icon-document"></i>内容管理</template>
        <el-menu-item index="/articles/create">新建文章</el-menu-item>
        <el-menu-item index="/articles/list">文章列表</el-menu-item>
      </el-submenu> 
    </el-menu>
  </el-aside>
  <!-- 主要内容容器 -->
  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <el-dropdown>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item index="/users/admin">
            <router-link to="/users/admin" class="adminbox">管理个人信息</router-link>
          </el-dropdown-item>
          
        </el-dropdown-menu>
      </el-dropdown>
      <span>用户 {{username}}</span>
    </el-header>
    <!-- 路由显示模块 -->
    <el-main>
      <!-- 插入路由组件 -->
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
</html>
</template>


<script>
  export default {
    data() {
      return {

        username:[]
       
      }
    },

methods:{        
        //获取页面数据
          updateUser(){
              //读取localStorage的数据
              const uData = localStorage.getItem('UserToken').split(' ')[1]
              const uName = uData.split('.')[1]
              //console.log( uName)
              this.username=uName
          },
          
        },  
    created(){
      /* 在created周期去后端获取数据； */
      this.updateUser();            
    },
}  
</script>


<style>
html,body{
  padding: 0;
  margin: 0;
}
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  /* title:'博客后台管理系统' */
  .el-aside {
    color: #333;
  }
  .adminbox{
    text-decoration:none;
    color:rgb(58, 56, 56)
  }
</style>



  

